<!DOCTYPE html>
<html lang="zh-cn">
<html>
<head>
<meta charset="utf-8" />
<title>基本配置</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<meta name="HandheldFriendly" content="true"/>
<meta name="MobileOptimized" content="320"/>
<%include file="../include/static.html"/>
</head>
<style>
*{padding:0px;margin:0px}
.el-header, .el-footer {background-color: #B3C0D1;line-height: 60px;padding:0px;}
.kcw-side-scroll::-webkit-scrollbar{width:0px;}
.el-table__header-wrapper {width: 100%;height:10px}
.el-tabs__content {
    overflow: hidden;
    position: relative;
    margin-top: -14px;
}
</style>
<body>
<div id="app">
<el-card class="box-card" style="width:47%;height:380px;float:left;margin:1%">
    <div slot="header" class="clearfix">
        <span>系统设置</span>
        <el-button style="float: right; padding: 3px 0" type="text"></el-button>
    </div>
    <el-form ref="form" :model="config" label-width="120px" size="mini">
        <el-form-item label="系统名称">
            <el-input v-model="config.system.name" placeholder=""></el-input>
        </el-form-item>
        <el-form-item label="系统logo">
            <el-input v-model="config.system.logo" placeholder="图标地址" style="width:80%"></el-input>
            <el-button @click="openurl('/intapp/imgmt?select=1')" size="mini">选择图片</el-button>
        </el-form-item>
        <el-form-item label="kcweb账号">
            <el-button size="mini">绑定</el-button>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="setbaseconfig('set')">保存</el-button>
        </el-form-item>
    </el-form>
</el-card>
<el-card class="box-card" style="width:47%;height:380px;float:left;margin:1%">
    <div slot="header" class="clearfix">
        <span>阿里云oss对象储存配置</span>
        <el-button style="float: right; padding: 3px 0" type="text" @click="openurl('https://oss.console.aliyun.com/overview')">前往官网</el-button>
    </div>
    <el-form ref="form" :model="config" label-width="120px" size="mini">
        <el-form-item label="地域节点">
            <el-input v-model="config.aliyun.address" placeholder="如：http://oss-cn-hangzhou.aliyuncs.com"></el-input>
        </el-form-item>
        <el-form-item label="阿里云存储桶">
            <el-input v-model="config.aliyun.bucket" placeholder="bucket"></el-input>
        </el-form-item>
        <el-form-item label="阿里云账号">
            <el-input v-model="config.aliyun.access_key" placeholder="access_key"></el-input>
        </el-form-item>
        <el-form-item label="阿里云密钥">
            <el-input v-model="config.aliyun.access_key_secret" placeholder="access_key_secret"></el-input>
        </el-form-item>
        <el-form-item label="阿里云备份目录">
            <el-input v-model="config.aliyun.backpath" placeholder="backpath"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="setbaseconfig('set')">保存</el-button>
        </el-form-item>
    </el-form>
</el-card>
</div>
</body>
<script>
var backup="";
var Vues=null;
function setimgmt(domain,paths,item){
    mysetfile(domain,paths,item)
    layer.closeAll();
}
Vues=new Vue({
    el: '#app',
    data:{
        kcwebimg:"${config.domain['kcwebimg']}",
        winheight:document.documentElement.clientHeight,winwidth:document.documentElement.clientWidth,
        config:{
            aliyun:{
                access_key:'',
                access_key_secret:'',
                address:'',
                backpath:'',
                bucket:''
            },
            system:{
                name:'',
                logo:'',
                kcwebuser:{}
            },
        },
    },
    mounted:function(){
        self=this
        window.onresize = function(){
            self.winheight=document.documentElement.clientHeight
            self.winwidth=document.documentElement.clientWidth
        }
        window.mysetfile = this.mysetfile;
        self.setbaseconfig('get')
    },
    methods: {
        mysetfile:function(domain,paths,item){
            if (item.suffix=='jpg' || item.suffix=='JPG' || item.suffix=='png' || item.suffix=='PNG' || item.suffix=='gif' || item.suffix=='GIF'){
                self.config.system.logo=domain+paths+item.name
            }else{
                self.$message({type: 'error',message: '请选择图片文件'});
            }
        },
        openurl:function(url){
            layer.open({
                type: 2,title: false,shadeClose: true,shade: 0.8,
                area: ['80%', '90%'],content:url
            }); 
        },
        setbaseconfig:function(types){
            self=this
            if(types=='set'){
                self.put("/intapp/index/setup/setbaseconfig/"+types,self.config,'请稍后...').then(function(res){
                    self.$notify({title: '成功',duration:5000,message:res.msg,type: 'success'});
                })
            }else{
                self.get("/intapp/index/setup/setbaseconfig/"+types,self.config,'请稍后...').then(function(res){
                    self.config=res.data
                    if(!self.config.system){
                        self.config.system={
                            name:'',logo:'',kcwebuser:{}
                        }
                    }
                })
            }
        }
    }
});
</script>
</html>